package com.gzx.plugin.tjzy.modular.excel.imports.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.modular.excel.imports.bo.GzxExcelImportQueryBo;
import com.gzx.plugin.tjzy.modular.excel.imports.service.GzxExcelImportService;
import com.gzx.plugin.tjzy.modular.excel.imports.vo.GzxExcelImportVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.common.pojo.CommonResult;

import java.io.IOException;

/**
 * @author zjt
 * @description
 * @date 2025/5/8 16:17
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/tjzy/excel/import")
public class GzxExcelImportController {

    private final GzxExcelImportService excelImportService;

    @PostMapping("/pageList")
    public CommonResult<Page<GzxExcelImportVo>> pageList(@RequestBody GzxExcelImportQueryBo excelImportQueryBo) {
        return CommonResult.data(excelImportService.pageList(excelImportQueryBo));
    }

    @PostMapping("/importExcel/{type}")
    public CommonResult<Void> importExcel(@PathVariable Integer type, @RequestParam("multipartFile") MultipartFile multipartFile) throws IOException {
        excelImportService.importExcel(type, multipartFile);
        return CommonResult.ok();
    }
}
